package com.woniu.zsd.permission.controller;


import com.woniu.zsd.commons.core.model.Result;
import com.woniu.zsd.permission.entity.Menu;
import com.woniu.zsd.permission.service.IRolesMenuService;
import com.woniu.zsd.permission.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-04-17
 */
@RestController
@RequestMapping("/roles-menu")
@Api(tags = "角色菜单管理")
public class RolesMenuController {
    @Autowired
    private TokenUtil tokenUtil;

    @Autowired
    private IRolesMenuService rolesMenuService;

    @GetMapping("/selMenuByAdminId")
    @ApiOperation(value = "根据管理员ID查询菜单")
    public Result<List<Menu>> selMenuByAdminId(@RequestHeader String token){
        Integer adminId = tokenUtil.getAdminId(token);
        return new Result<List<Menu>>().setData(rolesMenuService.selMenuByAdminId(adminId)).setMsg("查询成功");
    }
}
